/*
 * BACKGROUND JOB
 */

#ifndef GKT_BG_JOB_H
#define GKT_BG_JOB_H

#include "gkt_types.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef GKT_CONFIG_BG_JOB_TABLE

/* job id */
#define GKT_BG_JOB_ID(name)	GKT_BG_JOB_ID_##name
#undef GKT_BG_JOB
#define GKT_BG_JOB(name)	GKT_BG_JOB_ID(name)
enum {
	GKT_CONFIG_BG_JOB_TABLE,
	GKT_BG_JOB_ID_MAX
};

enum {
	GKT_BG_JOB_PRIORITY_HIGH = 0,
	GKT_BG_JOB_PRIORITY_MEDIUM,
	GKT_BG_JOB_PRIORITY_LOW,
	GKT_BG_JOB_PRIORITY_MAX
};
#define GKT_BG_JOB_F_PRIORITY_MASK	0xf
#define GKT_BG_JOB_F_SYNC	(1U << 8)

typedef void (*gkt_bg_job_handler)(void);

int gkt_bg_job_init(void);

void gkt_bg_job_register(uint32_t job_id, 
				gkt_bg_job_handler job_handler);

void gkt_bg_job_enable(void);

int gkt_bg_job_start(uint32_t job_id, uint32_t flags);

int gkt_bg_job_sync_complete(void);

#else

#define GKT_BG_JOB_ID(name)	0
#define GKT_BG_JOB_ID_MAX	0

#define gkt_bg_job_init()	GKT_ENOTSUPPORT
#define gkt_bg_job_register(job_id, job_handler)	do {} while(0)
#define gkt_bg_job_enable()	do {} while(0)
#define gkt_bg_job_start(job_id, flags)	GKT_ENOTSUPPORT
#define gkt_bg_job_sync_complete()	1

#endif

#ifdef __cplusplus
}
#endif

#endif	/* GKT_BG_JOB_H */
